/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uns.fit.gis.serviceapp;

import java.util.Calendar;
import java.util.Timer;

/**
 *
 * @author Ninh
 */
public class Connector {

    public static Service1Soap_Stub service;
    public static task t;
    public static Timer timer;
   

    public static void startConnection() {
        service = new Service1Soap_Stub();
        timer = new Timer();
        service._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, "http://giscellid.zapto.org:2000/index.asmx");
        t = new task(service);
        
        timer.schedule(t, 0, 2000);
    }

    public static double[] getLastPosition(){
        try {
            ArrayOfDouble arr = service.tinhVT(t.getImei(), null);
            return arr.get_double();
        } catch (Exception e) {
        }
        return null;
    }

    public static void stopConnection()
    {
        try {
            service.deleteXML(t.getImei());
        } catch (Exception e) {
        }
        timer.cancel();
    }
}
